<template>
	<div class="content">

		<div style="height: 35px;">
			<div style="display: inline-block; width: 8%;"></div>
			<el-button type="info" size="mini" icon="el-icon-circle-close" round @click="deleteAll()">全部删除</el-button>
		</div>

		<div v-for="(l, index) in inf">
			<el-card shadow="hover">
				<div style="width: 90%; margin: 0 auto;">
					<div>
						<div style="display: inline-block; width: 52%;">您关注的学者发布了新的论文</div>
						<div style="display: inline-block; width: 34%;">{{ l.time }}</div>
						<div style="display: inline-block; width: 7%;">
							<i class="el-icon-delete delete" @click="deleteOne(index)"></i>
						</div>
						<div style="display: inline-block; width: 7%;">
							<i class="el-icon-more delete" @click="gotoLiterature(l.lid)"></i>
						</div>
					</div>
					<hr size=1px style="border: 0; background-color: #eee; height: 1px;">
					<div style="line-height: 22px; font-size: 14px">
						<div class="link" @click="gotoLiterature(l.lid)" style="font-size: 19px; line-height: 35px;">
							{{ l.headline }}</div>
						<div>{{ l.abstract }}</div>
						<div class="link" @click="gotoAuther(l.aid)">{{ l.auther }}</div>
					</div>
				</div>
			</el-card>
			<div style="height: 10px;"></div>
		</div>

	</div>
</template>

<script>
	export default {

		name: "personalInf",
		components: {},
		data() {
			return {

				is_loading: true,

				inf: [{
					lid: "3",
					aid: "4",
					headline: "论述软件工程技术发展思索与应用",
					abstract: "软件作为一种特别的产品,软件的发展规模与繁琐性不断地提高.本文主要从四个层面对软件工程技术的发展进行一些思索:第一,就事物发展规律的视角,阐述了软基工程技术的发...",
					auther: "侯国熙",
					time: "2019-10-28 23:12:04"
				}, {
					lid: "5",
					aid: "6",
					headline: "论述软件工程技术发展思索与应用1",
					abstract: "软件是一种特殊的产品,随着科学技术发展,软件在规模还有繁琐性等方面也逐渐提高.本文主要从几个角度对软件工程的技术发展进行阐述:(1)事物发展规律角度;(2)软件本质特...",
					auther: "王岩",
					time: "2019-10-27 23:12:04"
				}, {
					lid: "7",
					aid: "8",
					headline: "论述软件工程技术发展思索与应用2",
					abstract: "软件是一种特殊的产品,随着科学技术发展,软件在规模还有繁琐性等方面也逐渐提高.本文主要从几个角度对软件工程的技术发展进行阐述:(1)事物发展规律角度;(2)软件本质特...",
					auther: "王岩",
					time: "2019-10-27 23:12:04"
				}, {
					lid: "9",
					aid: "10",
					headline: "论述软件工程技术发展思索与应用3",
					abstract: "软件是一种特殊的产品,随着科学技术发展,软件在规模还有繁琐性等方面也逐渐提高.本文主要从几个角度对软件工程的技术发展进行阐述:(1)事物发展规律角度;(2)软件本质特...",
					auther: "王岩",
					time: "2019-10-27 23:12:04"
				}, {
					lid: "11",
					aid: "12",
					headline: "论述软件工程技术发展思索与应用4",
					abstract: "软件是一种特殊的产品,随着科学技术发展,软件在规模还有繁琐性等方面也逐渐提高.本文主要从几个角度对软件工程的技术发展进行阐述:(1)事物发展规律角度;(2)软件本质特...",
					auther: "王岩",
					time: "2019-10-27 23:12:04"
				}, {
					lid: "13",
					aid: "14",
					headline: "论述软件工程技术发展思索与应用5",
					abstract: "软件是一种特殊的产品,随着科学技术发展,软件在规模还有繁琐性等方面也逐渐提高.本文主要从几个角度对软件工程的技术发展进行阐述:(1)事物发展规律角度;(2)软件本质特...",
					auther: "王岩",
					time: "2019-10-27 23:12:04"
				}, {
					lid: "15",
					aid: "16",
					headline: "论述软件工程技术发展思索与应用6",
					abstract: "软件是一种特殊的产品,随着科学技术发展,软件在规模还有繁琐性等方面也逐渐提高.本文主要从几个角度对软件工程的技术发展进行阐述:(1)事物发展规律角度;(2)软件本质特...",
					auther: "王岩",
					time: "2019-10-27 23:12:04"
				}],

			}
		},

		mounted() {
			const that = this;
			that.is_loading = true;
			that.axios.post("/", {
				uid: that.$store.state.uid
			}).then(
				function(response) {
					response.data.data.inf.forEach((i) => {
						that.inf.push(i);
					})
				},
				function() {}
			).finally(() => this.is_loading = false)
		},

		methods: {

			gotoAuther(aid) {
				let url = this.$router.resolve({
					path: '/',
					query: {
						aid: aid
					}
				});
				window.open(url.href, '_blank');
			},
			gotoLiterature(lid) {
				let url = this.$router.resolve({
					path: '/',
					query: {
						lid: lid
					}
				});
				window.open(url.href, '_blank');
			},
			deleteOne(index) {
				this.inf.splice(index, 1);
				this.axios({
					method: 'post',
					url: '',
					data: {
						uid: this.$store.state.uid,
						index: index
					},
					headers: {
						'X-CSRFToken': this.getCookie('csrftoken')
					},
				}).then(res => {
					var obj = res.data
					if (obj.code == 0) {
						this.$message.error({
							message: "删除失败",
							center: true
						});
					} else {
						this.$message.success({
							message: "删除成功",
							center: true
						});
					}
				}).catch(err => {
					console.log(err);
				})
			},
			deleteAll() {
				this.inf.splice(0, this.inf.length);
				this.axios({
					method: 'post',
					url: '',
					data: {
						uid: this.$store.state.uid
					},
					headers: {
						'X-CSRFToken': this.getCookie('csrftoken')
					},
				}).then(res => {
					var obj = res.data
					if (obj.code == 0) {
						this.$message.error({
							message: "删除失败",
							center: true
						});
					} else {
						this.$message.success({
							message: "删除成功",
							center: true
						});
					}
				}).catch(err => {
					console.log(err);
				})
			},
			getCookie(name) {
				var value = '; ' + document.cookie;
				var parts = value.split('; ' + name + '=');
				if (parts.length === 2) return parts.pop().split(';').shift();
			}

		}
	}
</script>

<style scoped>
	.content {
		width: 38em;
		height: 25em;
	}

	.link {
		width: fit-content;
		color: rgb(201, 160, 201);
	}

	.link:hover {
		cursor: pointer;
		text-decoration: underline
	}

	.delete:hover {
		cursor: pointer;
		color: rgb(201, 160, 201);
	}
</style>
